package com.dys.testequals;

/**
 * @className: com.dys.testeques.Phone
 * @description: 手机类
 * @author: pine cone
 * @version: v1.0.0
 * @createTime: 2024/07/20 下午1:55
 */
public class Phone {
    // 属性封装
    private String brand;
    private double price;
    private int year;
    // 方法

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getYear() {
        return year;
    }

    public void setYear(int year) {
        this.year = year;
    }

    // 构造器
    public Phone() {
    }

    public Phone(String brand, double price, int year) {
        this.brand = brand;
        this.price = price;
        this.year = year;
    }

    @Override
    public String toString() {
        return "Phone = {brand=" + brand + ", price=" + price + ", year=" + year + "}";
    }

    @Override
    public boolean equals(Object obj) {
        // 转型
        Phone other = (Phone) obj;
        if (this.brand == other.brand && this.price == other.price && this.year == other.year) {
            return true;
        }
        return false;
    }
}
